1. Technical Field
The present invention relates generally to techniques for determining a browser type in a Java runtime environment.
2. Description of the Related Art
Java, originally developed by Sun Microsystems, is a known software programming environment in which software programs, known as Java applets or applications, are developed, tested and maintained. Java programs have found extensive use on the World Wide Web, which is the Internet""s multimedia information retrieval system.
To have Java applets that provide interesting browser-side functionality usually requires extra-sandbox privileges or security exemptions. In the prior art, applet developers requiring security had two choices when creating applets. They could write two applets that individually exploited the functionality of the different web browsers (i.e. Netscape Navigator and Microsoft Internet Explorer) or they could create one applet that generically called the security methods available in each browser. In either case, however, the applet would be tied to the version of the Java Runtime Environment (JRE) shipped with the browser. Thus, applet developers have been unable to take advantage of new JREs and the functionality that they contain.
Recently, however, Sun""s JavaSoft introduced the Java 2 development platform. The Java 2 Java runtime environment (JRE) includes a plug-in that allows developers and users to run applets in their web browsers with different JREs. Using JavaSoft""s Java Plug-in, applets can be run in Internet Explorer or Netscape Communicator using a Java Runtime Environment (JRE) selected by the user. This enables applets to run in an open Java environment, namely, one that is not tied to proprietary classes and methods provided by the browser.
One problem with this scenario is that the true identity of the browser is masked by the Java Plug-in and there is no way to determine the actual browser environment. In particular, Java 2 does not provide any core Java class to consult for parent process information. Knowing the operating environment becomes important if applet or Java core classes need to perform operations in one environment but not in the other. For example, it may be desirable to emulate Microsoft interfaces in an Internet Explorer environment but not in Netscape; likewise, it may be desirable to emulate Netscape interfaces when running in Communicator but not in Internet Explorer.
In a native browser environment, a number of Java properties reflect the browser identity. The value of various Java properties in different operating environments is quite varied, and the Java Plugin masks the running browser""s true identity. It is known in the prior art how to determine the browser environment when the browser""s native JVM is being used. In the past, this has been accomplished by querying a java.vendor property or by making various calls to the netscape.javascript package (which is supported by Internet Explorer). However, there is no method known in the art for determining the browser environment when the browser has loaded a nonbrowser JRE via the Java Plugin.
Thus, there is a need to provide a technique to determine a browser identity while operating, for example, in the Java Plugin open environment. The present invention solves this problem.
In a preferred embodiment, a method is provided for determining an identity of a browser in an Java environment in which an intermediary program masks the browser""s identity. The method begins by querying an operating system process table for information identifying the browser. Thereafter, Java properties including the information from the process table are set. In response to a request from a calling program (e.g., an applet class) for the browser identity, a getproperty method is then called to retrieve the browser identity from the properties table. The browser identity is then returned to the calling program.
In accordance with an illustrative embodiment, a trusted Java class is modified according to the present invention to include several operations in its static initialization. The trusted class loads a native method dynamic link library (.dll) and calls an appropriate method that returns the current process name. The process name is then used by a given method (e.g., System.setProperty method) to set a set of Java properties, e.g., java.vendor, browser.vendor and browser. When an applet or core Java class needs to know its true browser environment, that class can call a public method (e.g., System.getProperty) with one of the properties to determine the browser type.
The foregoing has outlined some of the more pertinent objects and features of the present invention. These objects should be construed to be merely illustrative of some of the more prominent features and applications of the invention. Many other beneficial results can be attained by applying the disclosed invention in a different manner or modifying the invention as will be described. Accordingly, other objects and a fuller understanding of the invention may be had by referring to the following Detailed Description of the Preferred Embodiment.